﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartCity.BasicData.Api.Write.Application.Command.Account;
using SmartCity.BasicData.Common;

namespace SmartCity.BasicData.Api.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AccountController : ControllerBase
    {
        private readonly IMediator mediator;

        public AccountController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加账号
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreateAccount(CreateAccountCommand command) {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 修改账号
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateAccount(UpdateAccountCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 逻辑删除账号
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelAccount(DelAccountCommand command)
        {
            return await mediator.Send(command);
        }

    }
}
